/**
 * @file      config_storage.h
 * @brief
 * @version   1.0
 * @date      2023.12.14
 *
 * @copyright Copyright (c) 2018 UCchip Technology Co.,Ltd. All rights reserved.
 *
 * Change Logs:
 * Date          Author       Notes
 * 2023.12.14    zhdiao       the first version
 *
 */

#ifndef __CONFIG_STORAGE_H__
#define __CONFIG_STORAGE_H__

#define CONFIG_FILE_NAME "config.json"
#define CONFIG_FILE_PATH "/reserve/config.json"

#define FACTORY_FILE_PATH "/reserve/facoty.json"

/**
 * @brief Get config.json file length, byte.
 *
 * @return file length or -RT_ERROR.
 */
int config_file_get_len(char *file);

/**
 * @brief Read data from config.json file.
 *
 * @param data Memory addr where the read data is stored.
 * @param size The length that needs to be read.
 * @return N bytes actually read or -RT_EINVAL open file failed, -RT_ERROR read file failed.
 */
int config_file_read(char *file, void *data, unsigned int size);

/**
 * @brief Write data to config.json file.
 *        Each write will overwrite the previous content, and reset the file length.
 *
 * @param data Memory addr where the data to be written is stored.
 * @param size The length that needs to be write.
 * @return N bytes actually written or -RT_EINVAL open file failed, -RT_ERROR write file failed.
 */
int config_file_write(char *file, const void *data, unsigned int size);

#endif // __CONFIG_STORAGE_H__
